// pages/News/orderChanel/orderChanel.js
var businessLogic = require('../../../utils/NetWork/Model/NewsbusinessLogic.js')
var WxParse = require('../../../utils/Component/wxParse/wxParse.js');
var common = require('../../../utils/common.js')
var orgid = common.getStorageSync("orgid")
var userid = common.getStorageSync("userid")
Page({

  /** 
   * 页面的初始数据
   */
  data: {
    content:[],
    title:"",
    ryid2: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  //2.2.2查询学校下频道
  onLoad: function (options) {
    this.setData({
      ryid2: options.id
    })
    this.list();
  },
  list: function () {
    // 第二步 传参
    let params = {
      "page": 1, "num": 1000, "orgid": orgid, "userid": userid, "searchField": "school", "searchValue":""+this.data.ryid2+""}
    //第三步 调用接口
    
    businessLogic.ChannelList(params, (res) => {
      console.log(res)
      //第五步 把获取的值，传入data
      var timearray = [];
      for (var a = 0; a < res.length; a++) {
        timearray[a] = res[a].school_agencyinformation_title
        if (timearray[a] == "" || timearray[a] == undefined) {
          timearray[a] = '';
        } else {
          timearray[a] = res[a].school_agencyinformation_title;
        }
      }
      this.setData({
        contenttitle: timearray,
        content:res
      })

    });

  },
  bindKeyInput: function (e) {
    this.setData({
      title: e.detail.value
    })
  },
  search2: function (event) {
    let params = { "page": 1, "num": 1000, "orgid": orgid, "userid": userid, "searchField": "title,school", "searchValue": "" + this.data.title + "," + this.data.ryid2 + "" }
    businessLogic.ChannelList(params, (res) => {
      this.setData({
       
        content: res
      });
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  alreadyOrder: function (event) {
    //跳转
    wx.navigateTo({
      url: "../alreadyOrder/alreadyOrder?id=" + event.currentTarget.dataset.id
    });
  },
})